let axios = require('axios').default

async function ocrReq(imgBase64) {
    const params = new URLSearchParams()
    params.append('image', imgBase64)
    let baiduOcr = 'https://aip.baidubce.com/rest/2.0/ocr/v1/accurate?access_token=24.9412ef2738a1666ddb204054363e4a2e.2592000.1622807131.282335-24111254'
    let res = await axios.post(baiduOcr, params, {
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
    if (res.status == 200) {
        res.data["status"] = 20000
        return res.data
    }
    return {
        "status": 20000
    }

}

module.exports = ocrReq